<template>
  <div class="content-sta">
    <!-- <cus-search>
      <cus-search-item>
        <Form :model="form" :label-width="80">
          <cusButton
            type="primary"
            class="mb_20"
            @onClick="$refs['cusUploadModal'].show()"
            >导入</cusButton
          >
        </Form>
      </cus-search-item>
    </cus-search> -->
    <div class="content-bottom">
      <div class="tableBox">
    <cus-card title="标准劳动营养强度表">
      <cusTable
        border
        :loading="form.loading"
        :columns="columns"
        :data="data"
      >
      
        <template slot-scope="{ row }" slot="lightWorker">
        {{
          row.lightWorker
        }}
        </template>
        <template slot-scope="{ row }" slot="moderateWorker">{{
          row.moderateWorker
        }}</template>
        <template slot-scope="{ row }" slot="heavyWorker">{{
          row.heavyWorker
        }}</template>
        <template slot-scope="{ row }" slot="limitWorker">{{
          row.limitWorker
        }}</template>
        <template slot-scope="{ row }" slot="surfaceShipPersonnel">{{
          row.surfaceShipPersonnel
        }}</template>
        <template slot-scope="{ row }" slot="submarinePersonnel">{{
          row.submarinePersonnel
        }}</template>
        <template slot-scope="{ row }" slot="nuclearSubmarinePersonnel">{{
          row.nuclearSubmarinePersonnel
        }}</template>
        <template slot-scope="{ row }" slot="pilots">{{
          row.pilots
        }}</template>
        <template slot-scope="{ row }" slot="max">{{
          row.max
        }}</template>
      </cusTable>
    </cus-card>
</div>
</div>
    <cus-uploadModal
      ref="cusUploadModal"
      :uploadFnc="uploadStandard"
      :showUpload="true"
      :showTemp="false"
      uploadLabel="导出基础数据"
      fileName="fileName"
      :cusParams="{
        id: 'RK1603518306003',
        name: 'undefined'
      }"
      accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
      @onOk="onInit"
    >
    </cus-uploadModal>
  </div>
</template>

<script>
import {
  getStandardNutritionList,
  uploadStandard
} from "@/api/organ/dishesModule";

export default {
  name: "",
  data() {
    return {
      uploadStandard: uploadStandard,
      form: {
        loading: false
      },
      columns: [
        {
          title: "营养类型",
          align: "center",
          width: "150",
          key: "nutritionType"
        },
        {
          title: "陆勤",
 
          align: "center",
          children: [
            {
              width: 110,
              title: "轻度劳动",
              slot: "lightWorker",
              align: "center"
            },
            {
              width: 110,
              title: "中度劳动",
              slot: "moderateWorker",
              align: "center"
            },
            {
              width: 110,
              title: "重度劳动",
              slot: "heavyWorker",
              align: "center"
            },
            {
              width: 110,
              title: "极重度劳动",
              slot: "limitWorker",
              align: "center"
            }
          ]
        },
        {
          title: "海勤",
          align: "center",
          children: [
            {
              width: 150,
              title: "水面舰艇人员",
              slot: "surfaceShipPersonnel",
              align: "center"
            },
            {
              width: 150,
              title: "潜艇人员",
              slot: "submarinePersonnel",
              align: "center"
            },
            {
              width: 150,
              title: "核潜艇人员",
              slot: "nuclearSubmarinePersonnel",
              align: "center"
            }
          ]
        },
        {
          title: "空勤",
          align: "center",
          children: [
            {
              minWidth: 120,
              title: "飞行人员",
              slot: "pilots",
              align: "center"
            }
          ]
        },
        {
          title: "耐受上限",
          width: 150,
          slot: "max",
          align: "center"
        }
      ],
      data: [],
      tableHeight: 0,
    };
  },
  computed: {},
  mounted() {
    setTimeout(() => {
      this.tableHeight = window.innerHeight - 174; // 表格自适应高度
    }, 100);
    window.addEventListener("resize", this.tableHeightChange, true);
    this.onInit();
  },
  methods: {
    onInit() {
      this.getStandardNutritionListApi();
    },
    // 获取伙食登记薄列表
    getStandardNutritionListApi() {
      this.form.loading = true;
      return new Promise(resolve => {
        getStandardNutritionList({
          starttime: this.form.startTime,
          endtime: this.form.endTime
        }).then(res => {
          if (res.code === 1) {
          
            this.form.loading = false;
            this.data = res.data;
            resolve();
          } else this.form.loading = false;
        });
      });

    },
    tableHeightChange() {
      this.tableHeight = 0;
      setTimeout(() => {
        this.tableHeight = window.innerHeight - 200; // 表格自适应高度
        console.log(this.tableHeight);
      }, 100);
    },
  },
  destroyed() {
    window.removeEventListener("resize", this.tableHeightChange, true);
  },
};
</script>

<style>
</style>
